package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOrderChangeTicketsH;
import com.ktgj.flight.service.IFlightOrderChangeTicketsHService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机票预订_机票退改签订单机票历史Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/hs")
public class FlightOrderChangeTicketsHController extends BaseController
{
    @Autowired
    private IFlightOrderChangeTicketsHService flightOrderChangeTicketsHService;

    /**
     * 查询机票预订_机票退改签订单机票历史列表
     */
    @PreAuthorize(hasPermi = "flight:h:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOrderChangeTicketsH flightOrderChangeTicketsH)
    {
        startPage();
        List<FlightOrderChangeTicketsH> list = flightOrderChangeTicketsHService.selectFlightOrderChangeTicketsHList(flightOrderChangeTicketsH);
        return getDataTable(list);
    }

    /**
     * 导出机票预订_机票退改签订单机票历史列表
     */
    @PreAuthorize(hasPermi = "flight:h:export")
    @Log(title = "机票预订_机票退改签订单机票历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOrderChangeTicketsH flightOrderChangeTicketsH) throws IOException
    {
        List<FlightOrderChangeTicketsH> list = flightOrderChangeTicketsHService.selectFlightOrderChangeTicketsHList(flightOrderChangeTicketsH);
        ExcelUtil<FlightOrderChangeTicketsH> util = new ExcelUtil<FlightOrderChangeTicketsH>(FlightOrderChangeTicketsH.class);
        util.exportExcel(response, list, "机票预订_机票退改签订单机票历史数据");
    }

    /**
     * 获取机票预订_机票退改签订单机票历史详细信息
     */
    @PreAuthorize(hasPermi = "flight:h:query")
    @GetMapping(value = "/{changeTicketIdH}")
    public AjaxResult getInfo(@PathVariable("changeTicketIdH") Long changeTicketIdH)
    {
        return AjaxResult.success(flightOrderChangeTicketsHService.selectFlightOrderChangeTicketsHById(changeTicketIdH));
    }

    /**
     * 新增机票预订_机票退改签订单机票历史
     */
    @PreAuthorize(hasPermi = "flight:h:add")
    @Log(title = "机票预订_机票退改签订单机票历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOrderChangeTicketsH flightOrderChangeTicketsH)
    {
        return toAjax(flightOrderChangeTicketsHService.insertFlightOrderChangeTicketsH(flightOrderChangeTicketsH));
    }

    /**
     * 修改机票预订_机票退改签订单机票历史
     */
    @PreAuthorize(hasPermi = "flight:h:edit")
    @Log(title = "机票预订_机票退改签订单机票历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOrderChangeTicketsH flightOrderChangeTicketsH)
    {
        return toAjax(flightOrderChangeTicketsHService.updateFlightOrderChangeTicketsH(flightOrderChangeTicketsH));
    }

    /**
     * 删除机票预订_机票退改签订单机票历史
     */
    @PreAuthorize(hasPermi = "flight:h:remove")
    @Log(title = "机票预订_机票退改签订单机票历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{changeTicketIdHs}")
    public AjaxResult remove(@PathVariable Long[] changeTicketIdHs)
    {
        return toAjax(flightOrderChangeTicketsHService.deleteFlightOrderChangeTicketsHByIds(changeTicketIdHs));
    }
}
